CHARTS

Food Consumption and CO2 Emissions

Heatmap

Photo by Markus Spiske on Unsplash

Photo by Markus Spiske on Unsplash

The Earth started to rebel when the carbon in the atmosphere began to swell…
— Donna Maltz


In the US, each household produces 48 tons of greenhouse gases. Food produces about 8 tons of emissions per household, or about 17% of the total. Worldwide, new reports suggest that livestock agriculture produces around half of all man-made emissions. We have to change how we produce and consume food, not just for environmental reasons, but because this is an existential issue for humans.

Let’s examine the situation.

Ingest data

country, food category, consumption per country, co2 emissions per country

#Load data
url_file <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-18/food_consumption.csv"
food_consumption <- read.csv(url_file)
food_consumption

Wrangle

group_by, summarise, select and join

#Select the top 10 countries by co2 emissions
country <- food_consumption %>% group_by(country)%>%summarise(total=sum(co2_emmission))%>%top_n(10)%>%select(1)

#create dataframe of top 10 countries
df <- food_consumption%>%select(1,2,4)%>% inner_join(country)
df

The Heatmap

Food consumption (kg/person/year) and co2 emissions (kg co2/person/year)

theme_opts <- theme(
    text = element_text(family = "inconsolata", size = 16), 
    plot.title = element_text(margin = margin(b = 10), color = "#22222b",face = "bold",size = 17),
    plot.subtitle = element_text(margin = margin(b = 25),color = "#22222b", size = 12),
    plot.caption = element_text(margin = margin(t = 20),color = "#22222b", size = 10),
    axis.text.x = element_text(color = "#22222b", margin = margin(t = 15)),
    axis.text.y = element_text(color = "#22222b"),
    panel.background = element_blank(),
    panel.border = element_blank(),
    panel.grid.major = element_blank(),
    plot.background = element_rect(fill = "#e7e7e7"),
    plot.margin = unit(c(1, 2, 1, 1), "cm"),
    legend.position='none'
)



v1 <-  
  ggplot(data=df,aes(x = country, y = fct_reorder(food_category,co2_emmission))) +
  geom_tile(aes(fill = co2_emmission), color = "#2b2b2b") +
  geom_text(aes(label = co2_emmission), color = "#22292F") +
  scale_fill_gradient(low = "#20b2aa", high = "#2072b2") +
  labs(x = "",y = "",
       title = "Top 10 countries with the highest CO2 emissions",
       subtitle = "On which food category do they emit the highest level of CO2?",
       caption = "Source:Tidy Tuesday\nVisualization: JuanmaMN (Twitter @Juanma_MN)") +
  scale_x_discrete(position = "top") +
  guides(fill = NULL) +
  theme_bw() +
  theme_opts


girafe(ggobj = v1, width_svg = 16, height_svg = 9,
      options = list(opts_sizing(rescale = TRUE, width = 1.0)))

References

Citation and data source

  • Citation and data source: R for Datascience GO